#include "StdAfx.h"
#include "VectorOrcos.h"

VectorOrcos::VectorOrcos(void):CVectorDinamic(25){


	

}

VectorOrcos::~VectorOrcos(void){
}


VectorOrcos::VectorOrcos(long increment):CVectorDinamic(increment){

}
long VectorOrcos::Afegir(const Orcs &orco){
	
	Orcs* orcos=new Orcs(orco);			
	return CVectorDinamic::Afegir((void*)orcos);
}


bool VectorOrcos::Inserir(const Orcs &orco,long index){


	Orcs *orcInse=new Orcs(orco);
	return CVectorDinamic::Inserir((void*)orcInse,index);
}


bool VectorOrcos::Llegir(long index,Orcs &orco){

	bool ret=false;
	void * dades=CVectorDinamic::Llegir(index);
	 
	if(dades!=NULL){
		 orco=*(Orcs*)dades;
		 ret=true;
	}
	
	return ret;
	 
}

bool VectorOrcos::Modificar(const Orcs &orco, long index){

	bool ret=false;
	void*element=CVectorDinamic::Llegir(index);//llegim el index que volem modificar.
	if(element!=NULL){
		*(Orcs*)element=orco;
		ret=true;
	}else{
		Orcs *orcModi=new Orcs(orco);
		return CVectorDinamic::Modificar((void*)orcModi,index);
	}
}

bool VectorOrcos::Esborrar(long index){

	bool ret=false;

	Orcs *orcoborrar=(Orcs*)CVectorDinamic::Llegir(index);

	if(orcoborrar!=NULL){
		delete orcoborrar;
		ret=CVectorDinamic::Esborrar(index);
	}else{
		return ret;
	}
}